<!--#include file="lib/utf-8.asp"-->
<!--#include file="lib/conn.asp"-->
<!--#include file="lib/saferequest.asp"-->
<%
If Not Session("MM_Reg") Then
	response.write("您没有登陆，请登陆后使用!<br>")
	response.write "<a href='javascript:history.go(-1)'> << 返回上一页</a><br> "
	response.end
End If
if Session("MM_Flag")<1 then
	response.write("您没有查询权限！<br>")
	response.write "<a href='javascript:history.go(-1)'> << 返回上一页</a><br> "
	response.End
end if
if Session("MM_Post")<>2 And Session("MM_Post")<>0 Then
	response.write("您没有此岗位操作权限！<br>")
	response.write "<a href='javascript:history.go(-1)'> << 返回上一页</a><br> "
	response.End
end If
	sch=trim(replace(request.QueryString("sch"),"'","''"))
	ksrq=trim(replace(request.QueryString("ksrq"),"'","''"))
	if ksrq<>"" then ksrq=cdate(ksrq)
	jsrq=trim(replace(request.QueryString("jsrq"),"'","''"))
	if jsrq<>"" then jsrq=cdate(jsrq)
	kssj=trim(replace(request.QueryString("kssj"),"'","''"))
	if kssj<>"" then kssj=cdate(kssj)
	jssj=trim(replace(request.QueryString("jssj"),"'","''"))
	if jssj<>"" then jssj=cdate(jssj)
	xdksrq=trim(replace(request.QueryString("xdksrq"),"'","''"))
	if xdksrq<>"" then xdksrq=cdate(xdksrq)
	xdjsrq=trim(replace(request.QueryString("xdjsrq"),"'","''"))
	if xdjsrq<>"" then xdjsrq=cdate(xdjsrq)
	tyr=SafeRequest("tyr",0)
	week=SafeRequest("week",0)
	If week="" Then cyr=0
	cyr=SafeRequest("cyr",0)
	If cyr="" Or cyr="承运人" Then cyr=0
	sql="select * from yb LEFT JOIN cl ON yb.cyr = cl.clid where "
	If Session("MM_Post")<>0 Then
		sql=sql&"post="&Session("MM_Post")&" and "
	End If
	if ksrq<>"" and jsrq<>"" then
		sql=sql&"(rq>=#"&ksrq&"# and rq<=#"&jsrq&"#) and "
	end if
	if xdksrq<>"" and xdjsrq<>"" then
		sql=sql&"(xdrq>=#"&xdksrq&"# and xdrq<=#"&xdjsrq&"#) and "
	end if
	if kssj<>"" and jssj<>"" then
		sql=sql&"(baozhangsj>=#"&kssj&"# and baozhangsj<=#"&jssj&"#) and "
	end if
	if tyr<>"托运人" Or tyr="" then
		sql=sql&"tyr='"&tyr&"' and "
	end if
	if cyr<>0 then
		sql=sql&"cyr="&cyr&" and "
	end if
	if week<>0 then
		sql=sql&"weekday(rq)="&week&" and "
	end if
	xx=saferequest("xx",0)
	sql=sql&"(tx like '%"&sch&"%' or cbbz like '%"&sch&"%' or hx like '%"&sch&"%' or tyr like '%"&sch&"%' or cyr like '%"&sch&"%' or dd like '%"&sch&"%' or cmhc like '%"&sch&"%' or tdh like '%"&sch&"%' or xh like '%"&sch&"%' or fh like '%"&sch&"%' or hz like '%"&sch&"%' or client like '%"&sch&"%') and xx like '%"&xx&"%' "
	'response.write sql
	'response.end
	sum_sql="select sum(dcf) as s_dcf,sum(yj) as s_yj from ("&sql&")"
	set rs_sum = Server.CreateObject("ADODB.Recordset")
	rs_sum.open sum_sql,conn,1,1
	If Not rs_sum.eof Then
		s_dcf=rs_sum("s_dcf")
		s_yj=rs_sum("s_yj")
	End If
	rs_sum.close
	sql=sql&"order by xdrq,id desc"




	'response.write sql
	set rs = Server.CreateObject("ADODB.Recordset")
	rs.open sql,conn,1,1
	If rs.eof Then
		response.write("没有检索到数据!")
		response.end
	End if
If saferequest("page",0)<>""  Then	page=clng(saferequest("page",0)) Else	page=1
pc=saferequest("pc",1)
If pc="" Then pc=25
rs.pagesize=pc
pagesize=rs.pagesize
pagecount=rs.pagecount
'page=clng(request.QueryString("page"))
if Not IsEmpty(page) then '如果page_num已经初始化...
	if Not IsNumeric(page) then '判断page_num值是否为数字
		page=1
	else
		page = clng(page) '接收page_num并化为数字型赋给page_num变量
	end if
	if page > pagecount then '如果接收的页数大于总页数
		rs.AbsolutePage = pagecount '设置当前显示页等于最后页
	elseif page <= 0 then '如果page小于等于0
		page=1
		rs.AbsolutePage = page '设置当前显示页等于第一页
	else
		rs.AbsolutePage = page '如果大于零,显示当前页等于接收的页数
	end if
	page = rs.AbsolutePage
end if
%>




<table class="contable">
	<thead>
  <tr>
    <th rowspan="2">序号</th>
    <th rowspan="2">货单日期</th>
    <th rowspan="2">托运人</th>
    <th rowspan="2">承运人</th>
    <th rowspan="2">货主</th>
    <th rowspan="2">地点</th>
    <th rowspan="2">时间</th>
    <th rowspan="2">详细厂名</th>
    <th rowspan="2">联系方式</th>
    <th rowspan="2">船名/航次</th>
    <th rowspan="2">提单号</th>
    <th rowspan="2">箱型</th>
    <th rowspan="2">箱号</th>
    <th rowspan="2">封号</th>
    <th rowspan="2">注意事项</th>
    <th rowspan="2">车队备注</th>
    <th colspan="2">成本费用</th>
    <th rowspan="2">下单日期</th>
  </tr>
  <tr>
	<th>提箱</th>
	<th>还箱</th>
  </tr>
	</thead>
	<tbody>
<%
'while not rs.eof
for i=1 to rs.pagesize
	if rs.EOF then	Exit For
%>
  <tr>
	<td><a class="iframe" href="view_cd.asp?id=<%=rs("id")%>"><%=rs.AbsolutePosition%></a></td>
	<td><%=rs("rq")%></td>
	<td><%=rs("tyr")%></td>
	<td><%=rs("clm")%></td>
	<td><%=rs("hz")%></td>
	<td><%=rs("dd")%></td>
	<td><%if Not isnull(rs("sj")) then response.write(FormatDateTime(rs("sj"),4))%></td>
	<td><%=rs("client")%></td>
	<td><%=rs("contacts")%></td>
	<td><%=rs("cmhc")%></td>
	<td><%=rs("tdh")%></td>
	<td><%=rs("xx")%></td>
	<td><%=rs("xh")%></td>
	<td><%=rs("fh")%></td>
	<td><%=rs("attentions")%></td>
	<td><%=rs("bz")%></td>
	<td><%=rs("tx")%></td>
	<td><%=rs("hx")%></td>
	<td><%=rs("xdrq")%></td>
  </tr>
<%
	sum_dcf=sum_dcf+rs("dcf")
	sum_yj=sum_yj+rs("yj")

	rs.movenext()
'wend
Next
%>
</tbody>
<thead>
  <tr>
    <th>小计</th>
		<th>&nbsp;</th>
		<th>&nbsp;</th>
		<th>&nbsp;</th>
		<th>&nbsp;</th>
		<th>&nbsp;</th>
		<th>&nbsp;</th>
		<th>&nbsp;</th>
		<th>&nbsp;</th>
		<th>&nbsp;</th>
		<th>&nbsp;</th>
		<th>&nbsp;</th>
		<th>&nbsp;</th>
		<th>&nbsp;</th>
		<th>&nbsp;</th>
		<th>&nbsp;</th>
		<th>&nbsp;</th>
		<th>&nbsp;</th>
		<th>&nbsp;</th>
  </tr>
  <%If page=rs.pagecount Then %>
  <tr>
    <th>总计</th>
		<th>&nbsp;</th>
		<th>&nbsp;</th>
		<th>&nbsp;</th>
		<th>&nbsp;</th>
		<th>&nbsp;</th>
		<th>&nbsp;</th>
		<th>&nbsp;</th>
		<th>&nbsp;</th>
		<th>&nbsp;</th>
		<th>&nbsp;</th>
		<th>&nbsp;</th>
		<th>&nbsp;</th>
		<th>&nbsp;</th>
		<th>&nbsp;</th>
		<th>&nbsp;</th>
		<th>&nbsp;</th>
		<th>&nbsp;</th>
		<th>&nbsp;</th>
  </tr>
  <% End If %>
	</thead>
</table>
	<span id="pagebar">
		<%	If page>1 Then	%>
			[<a href="#" id="1">首页</a>]
			[<a href="#" id="<%=page-1%>">上一页</a>]
		<%
				End If
				If Not (page>=pagecount Or pagecount=0) Then
		%>
			[<a href="#" id="<%=page+1%>">下一页</a>]
			[<a href="#" id="<%=pagecount%>">尾页</a>]
		<%	End If %>
			第 <%=page%> 页 / 共 <%=pagecount%> 页
			转到<input id="page_val" type="text" size="2" maxlength="<%=Int(Log(pagecount))+1%>" value="<%=page%>" />页
			<input id="page_go" type="button" value="Go" />
	</span>
<%
rs.close
Set rs=Nothing
conn.close
Set conn=nothing
%>

